#include "Comm.hpp"
#include "Fifo.hpp"
#include <unistd.h>

int main()
{
    key_t key = GetShmKey();
    std::cout << "key: " << ToHex(key) << std::endl;

    int shmid = GetShm(key, defaultsize);
    std::cout << "shmid: " << shmid << std::endl;

    char *addr = (char *)ShmAttach(shmid);
    std::cout << "Attach shm success, addr: " << ToHex((uint64_t)addr) << std::endl;

    memset(addr, 0, defaultsize);
    Sync syn;
    syn.OpenWrite();
    char buffer[1024] = "i am process A";
    strcpy(addr,buffer);
    syn.Wakeup();
    cout << "写入成功" << endl;

    ShmDetach(addr);
    std::cout << "Detach shm success, addr: " << ToHex((uint64_t)addr) << std::endl;
    sleep(5);

    return 0;
}